<?php
error_reporting("E_ALL");ini_set("display_errors", 1);
$getdata=$_REQUEST;
if(empty($getdata))$getdata=$_POST?$_POST:$_GET;
$type=empty($getdata['type'])?'':$getdata['type'];
include("include/function.php");
//header("content-Type: application/json; charset=utf-8");
$config = include("config.php");
include("include/".$config['DB_TYPE'].".class.php");
$db = new db;
$db->connect($config['DB_HOST'],$config['DB_USER'],$config['DB_PWD'],$config['DB_NAME'], $config['DB_PCONNECT']);
$arr = array(
            0 => array('id' => '4e0cfe473c2048b19be967827f07595e','name' => '百花二小','school_id' => 79,'num'=>66),
            1 => array('id' => '5111cec103e64ed198e5c46d092bac0f','name' => '百花小学','school_id' => 12,'num'=>469),
            2 => array('id' => '673ca7a74e17438e986f3592d2d9d9cd','name' => '爆台寺小学','school_id' => 39,'num'=>84),
            3 => array('id' => '1d858a81f75d4d7d952e95484324087f','name' => '北屯头小学','school_id' => 41,'num'=>77),
            4 => array('id' => 'f926d3ed00cb4e45a4fe201ae7919bbd','name' => '丛台区安居实验小学','school_id' => 35,'num'=>149),
            5 => array('id' => 'ae2cbf92f0e548bdaa1a40fdc811ca7d','name' => '丛台区丛台第二小学','school_id' => 47,'num'=>62),
            6 => array('id' => '4fe94342b0024d73889238ffd62d008b','name' => '丛台区丛台第三小学','school_id' => 83,'num'=>22),
            7 => array('id' => 'a3e2f6391ac249f1aaad96321c32a1af','name' => '丛台区东门外小学','school_id' => 40,'num'=>46),
            8 => array('id' => '82bae894ac9c4d28a3531f498ef15172','name' => '丛台区滏东小学','school_id' => 44,'num'=>142),
            9 => array('id' => '81ad097cd5bf4ac584e877ffcaff3c89','name' => '丛台区河西小学','school_id' => 38,'num'=>41),
            10 => array('id' => '2337983ac7004a3989fb55ce28ac144e','name' => '丛台区连城小学','school_id' => 27,'num'=>366),
            11 => array('id' => 'cddd2f329dc0405d8ebd3f7ec3f150f3','name' => '丛台区南苏曹小学','school_id' => 46,'num'=>73),
            12 => array('id' => '4325914f15224f4087deb5ffc999db1b','name' => '丛台区沁河小学','school_id' => 37,'num'=>76),
            13 => array('id' => '114bbb605f0d4568a8351bee1e49e028','name' => '丛台区十里铺小学','school_id' => 42,'num'=>47),
            14 => array('id' => 'd91a84b3891f46b4b2bf8a4ca0d00d4c','name' => '丛台区实验第二小学','school_id' => 77,'num'=>39),
            15 => array('id' => '1e47938f242f47fd8ccf0161a06fc260','name' => '丛台区实验小学北校区','school_id' => 84,'num'=>72),
            16 => array('id' => '3ba77b6ed6cb479aa23d64727da44928','name' => '丛台区五里铺小学','school_id' => 43,'num'=>84),
            17 => array('id' => 'dc46edf93766474e9b52af43e70b0420','name' => '丛台小学','school_id' => 70,'num'=>320),
            18 => array('id' => 'f1271c3b106c4c9e9941d049d2c453d6','name' => '丛阳小学','school_id' => 24,'num'=>396),
            19 => array('id' => '7c3c50943d99448c97e010c95d5a692b','name' => '东耒马台小学','school_id' => 63,'num'=>63),
            20 => array('id' => '5a9e7f89be76446e86e74d66de4a5e0f','name' => '东尚壁小学','school_id' => 51,'num'=>105),
            21 => array('id' => '84ed497f8c9049febc1577cac48a06c3','name' => '东孙庄小学','school_id' => 48,'num'=>55),
            22 => array('id' => '03e25a6ec7d64fa8b9ab077701a992fa','name' => '东辛庄学校','school_id' => 73,'num'=>43),
            23 => array('id' => '6bf84ae7c3aa4734a8e7dd9e9031b46a','name' => '纺机路小学','school_id' => 58,'num'=>32),
            24 => array('id' => 'c69db6c394204ad59de749286b4d7f65','name' => '复兴区八一小学','school_id' => 85,'num'=>13),
            25 => array('id' => '6ca62eb666ab497f97bfc3600d8679df','name' => '复兴区第二实验小学','school_id' => 86,'num'=>199),
            26 => array('id' => '3ed687ebc7a346e48e44be4011f6362d','name' => '复兴区第三中学','school_id' => 78,'num'=>125),
            27 => array('id' => '1ce8d3abb0704e7c899f3f692b10d340','name' => '复兴区东邢台小学','school_id' => 56,'num'=>11),
            28 => array('id' => '586e3c3ce0924768bddd775b8cfd88ed','name' => '复兴区实验小学','school_id' => 29,'num'=>198),
            29 => array('id' => 'cf09302d9762472db33ce612bdcb5c20','name' => '复兴西大屯小学','school_id' => 57,'num'=>5),
            30 => array('id' => 'a43d72afd81f4ee3891baf61f3c0b2b7','name' => '复兴西小屯小学','school_id' => 62,'num'=>12),
            31 => array('id' => 'f2677dc1c6f54c3baf8b2f9c24d41801','name' => '复兴小学','school_id' => 66,'num'=>182),
            32 => array('id' => '1fb52e05de8349609831f438adee9104','name' => '广安小学','school_id' => 16,'num'=>273),
            33 => array('id' => 'dd4860329f114048880b9b6b42ac8ee2','name' => '邯郸市丛台区春光小学','school_id' => 26,'num'=>289),
            34 => array('id' => '6d50f35f9fa6475dbc1bafb15c7bee75','name' => '邯郸市丛台区实验小学','school_id' => 18,'num'=>617),
            35 => array('id' => '525738fb1d7c40c3bfd328c5c970f43e','name' => '邯郸市丛台区曙光第六小学','school_id' => 87,'num'=>22),
            36 => array('id' => '83bda5b509b8433b8fe85fe1d5d2b61b','name' => '邯郸市丛台区曙光第四小学','school_id' => 76,'num'=>112),
            37 => array('id' => 'df6df03953354f92ad3f1ae3c6a3e94e','name' => '邯郸市丛台区荀子实验小学','school_id' => 32,'num'=>339),
            38 => array('id' => '10c47d3bab6b4099b09b867e355ab1a9','name' => '邯郸市丛台区逸夫艺术小学','school_id' => 31,'num'=>140),
            39 => array('id' => '6227dc738a764ed3a2b34a54b5836dc1','name' => '邯郸市复兴区第一中学','school_id' => 88,'num'=>0),
            40 => array('id' => '36a1444d3257477d9e22a5f02b066f6d','name' => '邯郸市复兴区美好小学','school_id' => 89,'num'=>20),
            41 => array('id' => 'cdf5e8508fed4b2282031bc262f24b4f','name' => '邯郸市实验小学','school_id' => 69,'num'=>460),
            42 => array('id' => '0acbad893a1648478e8e29104c2ef3f0','name' => '邯郸市赵苑中学','school_id' => 68,'num'=>166),
            43 => array('id' => 'f550e3c0a9434b2bb319d663c9a1c40c','name' => '邯郸学院附属第二小学','school_id' => 90,'num'=>22),
            44 => array('id' => '451a3f222cbf4486bbfd65ac91fbb42f','name' => '邯郸学院附属第一小学','school_id' => 91,'num'=>64),
            45 => array('id' => 'a0e785e166884d30bc9117629025acfd','name' => '汉霸庄学校','school_id' => 74,'num'=>66),
            46 => array('id' => '28ab6536790f4264a080ccd863122c03','name' => '和平小学','school_id' => 22,'num'=>161),
            47 => array('id' => '9fb77e8b95644877af2a87a930bccc35','name' => '贾口小学','school_id' => 52,'num'=>73),
            48 => array('id' => '2a4e8a4de24248b0880bb6ef3d8cdf64','name' => '建北小学','school_id' => 55,'num'=>160),
            49 => array('id' => '19ba55023b01419f991b7c8bf172c58e','name' => '箭岭小学','school_id' => 9,'num'=>210),
            50 => array('id' => '49199a0c75a44c2bb3a7f05a6da4051f','name' => '经开区刘庄小学','school_id' => 92,'num'=>50),
            51 => array('id' => 'a27d62b859ee425e9e16e29bc9e5a3ec','name' => '经开区实验第三小学','school_id' => 93,'num'=>177),
            52 => array('id' => '6c0c83b763434f998577692706da96f9','name' => '开发区实验学校','school_id' => 54,'num'=>296),
            53 => array('id' => 'ee8056cc13c244068ff480fbf222a28c','name' => '黎明小学','school_id' => 20,'num'=>333),
            54 => array('id' => '601f6efdcbec4ead8c2d0f6c726d507e','name' => '岭南小学','school_id' => 10,'num'=>92),
            55 => array('id' => 'f704a7abb2b749c6afc440a340caaa31','name' => '岭南小学光华校区','school_id' => 13,'num'=>143),
            56 => array('id' => '38d76f53db40408d8a85527fca4c801d','name' => '南屯头小学','school_id' => 36,'num'=>4),
            57 => array('id' => 'd07ca0e0065042f5ae97c0633a4077fd','name' => '庞村小学','school_id' => 61,'num'=>308),
            58 => array('id' => 'c1d9ad049883417dbc4904958ad62f52','name' => '前进小学','school_id' => 14,'num'=>49),
            59 => array('id' => 'b69846e164504ff68c363acfceb08987','name' => '沁园小学','school_id' => 11,'num'=>199),
            60 => array('id' => '752252ff715046b2ab19f417ac293b7e','name' => '人民小学','school_id' => 15,'num'=>128),
            61 => array('id' => '6d0e816dec244f58bd965d56b6d0a12c','name' => '时光小学','school_id' => 94,'num'=>233),
            62 => array('id' => '1aa8531d028146b59107406eac541abc','name' => '世纪路小学','school_id' => 33,'num'=>176),
            63 => array('id' => 'e6c005dd1c774afd87eafcdff3a67168','name' => '曙光第二小学','school_id' => 30,'num'=>200),
            64 => array('id' => '9d19bf6befab48ac82abee48710ac9f2','name' => '曙光第三小学','school_id' => 95,'num'=>709),
            65 => array('id' => 'a2dcaf430d204ec2aeafeffc51393be8','name' => '曙光小学','school_id' => 25,'num'=>129),
            66 => array('id' => 'a8b3a1ba930440c99301bc1e819ceeab','name' => '铁路小学','school_id' => 59,'num'=>210),
            67 => array('id' => '63607b208df34f41b551b34520f8ddd3','name' => '外国语小学','school_id' => 65,'num'=>87),
            68 => array('id' => 'c4004360513443b8a314883f19a154c9','name' => '西耒马台小学','school_id' => 72,'num'=>20),
            69 => array('id' => '2851c1d10bfd4971b5c49df078763c52','name' => '西尚壁小学','school_id' => 49,'num'=>174),
            70 => array('id' => 'afe387694b39446e866bc1dab8c83e6c','name' => '西孙庄小学','school_id' => 45,'num'=>77),
            71 => array('id' => 'da42e77ea7944a94adee77736be12650','name' => '西鸭池小学','school_id' => 50,'num'=>124),
            72 => array('id' => '66881f998853499781350c55ff96878a','name' => '学步桥小学','school_id' => 21,'num'=>234),
            73 => array('id' => 'bf6b8aa9c4434615aa686aee7c63d19b','name' => '荀子第二小学','school_id' => 67,'num'=>274),
            74 => array('id' => '9bc9a5950a67400ba5082aaf9e67e8c7','name' => '荀子第三小学','school_id' => 81,'num'=>46),
            75 => array('id' => '2f3e246e258a4365931ad453f8aa8c83','name' => '阳春小学','school_id' => 28,'num'=>172),
            76 => array('id' => 'e3884c9bf246439f90a9fd0d00fbecc3','name' => '永和学校','school_id' => 23,'num'=>164),
            77 => array('id' => '159798c2f0124e4f9fe50fc9b128e3c5','name' => '展览路第二小学','school_id' => 96,'num'=>28),
            78 => array('id' => '658d3a3ad1b14d839e3e4bb73f0cdfcb','name' => '展览路小学','school_id' => 64,'num'=>422),
            79 => array('id' => '5b9b8a54e70842728bedb12b4fcbfe13','name' => '赵都小学','school_id' => 19,'num'=>166),
            80 => array('id' => '461f205df01642b9882ee162ba726d70','name' => '赵王城学校','school_id' => 60,'num'=>49),
            81 => array('id' => '05f52ece52134b66a954f10cc51f098a','name' => '中华桥小学','school_id' => 17,'num'=>347),
            82 => array('id' => 'a1fa66638e5948b48065f6f7984fbf45','name' => '紫薇苑小学','school_id' => 53,'num'=>166),
);
        
$page = empty($getdata['page'])?1:$getdata['page'];
$id = empty($getdata['id'])?0:$getdata['id'];
if(empty($arr[$id]))exit('over');
$length=10;
$start=($page-1)*$length;
$end =$start+$length;

$post=[];
$post['draw']='4';
$post['start']=$start;
$post['length']=$length;
$post['token']='cb08c5896ea94614a48e00a82cccfd17.SC_EDU_WEB';
$post['unitId']=$arr[$id]['id'];
$post['condKey']='studentName';
$post['condValue']='';
$url='https://hdzycf.xyt360.com.cn/kitchen/web/patriarch/getListByPaginate';
$result = http_post($url,http_build_query($post),array('Content-Type: application/x-www-form-urlencoded'),'rmbUser=true; userName=admink');
$content=json_decode($result,1);$insert=0;
if(!empty($content['data'])){
    foreach($content['data'] as $k=>$v){
        $check = $db->get_one("select id from user where uuid='".$v['uuid']."'");
        if(empty($check)){
            $sql = "insert into user(`".implode('`,`',array_keys($v))."`) values('".implode("','",$v)."');";
            $db->query($sql);$insert++;
        }
        echo $v['uuid'].'=>'.$v['studentName']."\n<br>";
    }
    $page++;
}else{print_r($content);
    $id++;$page=1;
}
if(empty($content) && $page<$arr[$id]['num']){sleep(3);echo $page.'<script>location.href="?page='.$page.'&id='.$id.'";</script>';
    exit;
}
$log = $id.$arr[$id]['name'].'导入成功,新增：'.$insert.'条';
echo $log.'<script>location.href="?page='.$page.'&id='.$id.'";</script>';

//echo count($sqlarr)."\n";
//echo implode(";\n",$sqlarr);
?>